package scribble;

public class PasswordGen {
	private int n_Columns;
	private int n_Rows;
	private String password;
	private int width, height;
	
	
	public  PasswordGen(ScribbleCanvas canvas, int width, int height){
		setVars(width, height);
		this.n_Columns=canvas.n_Columns;
		this.n_Rows=canvas.n_Rows;
		password="";
	}
	
	public String getPassword(){
		return password;
		
	}
	
	public void setVars(int width, int height){
		this.width=width;
		this.height=height;
	}
	
	
	public void setPassord(int px, int py, int canvasX, int canvasY){	

		int pxi, pyi,canvasXi,canvasYi;
		
		pxi=(px*n_Columns)/width;
		pyi=(py*n_Rows)/height;
		canvasXi=(canvasX*n_Columns)/width;
		canvasYi=(canvasY*n_Rows)/height;

		if(pxi!=canvasXi || pyi!=canvasYi){			
			
			if((pxi!=n_Columns && pyi!=n_Rows)){
				password=password+((Integer.toString((int) pxi)) + (Integer.toString((int) pyi)));
			}
		}	
		
		
	}
	
	public void clearPassword(){
		password="";
	}
	
	
}
